package com.itheima.reggie.Controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.Service.OrderService;
import com.itheima.reggie.exception.R;
import com.itheima.reggie.pojo.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @RequestMapping("/submit")
    public R<String> order(@RequestBody Orders orders)
    {
 orderService.submit(orders);

 return R.success("成功");
    }
    @GetMapping("/userPage")
    public  R<Page> page(int page, int pageSize)
    {
      Page pageInfo=new Page(page,pageSize);
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.orderByAsc("order_time");
      orderService.page(pageInfo,queryWrapper);
        return R.success(pageInfo);

    }
}
